﻿<script type="text/template" id="flow-form-template">
    <div id="flow-form-error"/>
    <form id="flow-form" onsubmit="return false;">
        <ul class="idata-form">
        <li class="title">
            <%= jsResources.lang.CreateFlowFlowFormTitle %>
        </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowFlowFormName %>    
                </span>
                <span>
                    <input type="text" name="Name" id="Name" required value="<%= model.Name %>"/>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowFlowFormDescription %>    
                </span>
                <span>
                    <textarea name="Description" id="Description" required><%= model.Description %></textarea>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowFlowFormDocTypeId %>    
                </span>
                <span>
                    <select name="DocTypeId" id="DocTypeId">
                        <%= VH.MakeOption(VOFFICE.CreateFlow.DocTypeList, model.DocTypeId) %>
                    </select>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowFlowFormCommon %>    
                </span>
                <span>
                    <input type="checkbox" name = "IsCommon" id="IsCommon" <%= model.IsCommon == true ? 'checked="checked"' : '' %> />
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowFlowFormActive %>    
                </span>
                <span>
                    <input type="checkbox" name = "IsActive" id="IsActive" <%= model.IsActive == true ? 'checked="checked"' : '' %> />
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowFlowFormDefault %>
                </span>
                <span>
                    <input type="checkbox" name = "IsDefault" id = "IsDefault" <%= model.IsDefault == true ? 'checked="checked"' : '' %> />
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%=  jsResources.lang.CreateFlowFlowFormDepartment %>
                </span>
                <span>
                    <select id="DepartmentId" name="DepartmentId">
                        <%= VH.MakeOption(VOFFICE.CreateFlow.DepartmentList, model.DepartmentId) %>
                    </select>
                </span>
            </li>
        </ul>
        <div class="clear"></div>
        <center style="margin-top:5px;">
            <input type="submit" value = "<%= model.id == 0 ? jsResources.lang.Create : jsResources.lang.Update %>" id="submit-flow"
            class="ui-button ui-widget ui-state-default ui-corner-all ui-state-hover" role="button" aria-disabled="false" />
        </center>
    </form>

</script>
<script type="text/template" id="node-form-template">
    <div id="node-form-error"/>
    <form id="node-form" onsubmit = "return false;">
        <ul class="idata-form">
        <li class="title">
            <%= jsResources.lang.CreateFlowNodeFormTitle %>
        </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowNodeFormName %>    
                </span>
                <span>
                    <input type="text" name="Node_Name" id="Node_Name"  value="<%= model.Name %>"/>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowNodeFormDescription %>    
                </span>
                <span>
                    <textarea name="Node_Description" id="Node_Description"><%= model.Description %></textarea>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowNodeFormRoleId %>    
                </span>
                <span>
                    <select name="Node_RoleId" id="Node_RoleId">
                        <%= VH.MakeOption(VOFFICE.CreateFlow.RoleList, model.RoleId) %>
                    </select>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowNodeFormIsDocNode %>    
                </span>
                <span>
                    <input type="checkbox" name = "Node_IsDocNode" id="Node_IsDocNode" <%= model.IsDocNode == true ? 'checked="checked"' : '' %> />
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowNodeFormIsStart %>    
                </span>
                <span>
                    <input type="checkbox" name = "Node_IsStart" id="Node_IsStart" <%= model.IsStart == true ? 'checked="checked"' : '' %> />
                </span>
            </li>
        </ul>
        <div class="clear"></div>
        <center>
            <input type="submit" value = "<%= model.id == 0 ? jsResources.lang.Create : jsResources.lang.Update %>" id="submit-node"
            class="ui-button ui-widget ui-state-default ui-corner-all ui-state-hover" role="button" aria-disabled="false"/>
        </center>
    </form>

</script>
<script id="node-grid-item-template" type="text/template">
    <% var uinLength = model.UserInNode.length %>
    <% var tinLength = model.TodoInNode.length %>
    <% var max = _.max([uinLength,tinLength]) %>    
    <tr class="first head">
        <td>
            <span class="title">
                <%= model.Name %>
                (<%=model.RoleName %>)
            </span>
        </td>
        <td>
            <span class="button-right">
                <a href="javascript:void(0);" class="blue edit-node-1"> <%= jsResources.lang.GridEdit %></a>
                <a href="javascript:void(0);" class="red delete-node"> <%= jsResources.lang.GridDelete %></a>&nbsp;
            </span>
        </td>
    </tr>
    <tr>
        <td colspan="2">
            <span> 
                <%= jsResources.lang.CreateFlowNodeFormDescription %>:&nbsp;   
            </span>
            <span>
                <%= model.Description %>
            </span>
        </td>
    </tr>
    <tr>
        <td>
            <span>
                  <%= jsResources.lang.CreateFlowNodeFormIsDocNode %> 
            </span>
            <span>
                <input type="checkbox" <%= model.IsDocNode == true ? 'checked="checked"' : '' %> name="Grid_Item_IsDocNode" class="Grid_Item_IsDocNode" />
            </span>
        </td>
        <td>
            <span>
                 <%= jsResources.lang.CreateFlowNodeFormIsStart %> 
            </span>
            <span>
                <input type="checkbox" <%= model.IsStart == true ? 'checked="checked"' : '' %> name="Grid_Item_IsStart" class="Grid_Item_IsStart" />
            </span>            
        </td>
    </tr>
    <tr class="<%= max == 0 ? "last" : '' %>">
        <td>
            <span>
                <a href="javascript:void(0);" class="blue add-use-in-node"><%= jsResources.lang.AddMore %></a>
                <a href="javascript:void(0);" class="yellow view-use-in-node"><%= jsResources.lang.ViewMore %></a>
                <%= jsResources.lang.CreateFlowNodeGridUserInNode %>
            </span>
        </td>
        <td>
            <span>
                <a href="javascript:void(0);" class="blue add-todo-in-node"><%= jsResources.lang.AddMore %></a>
                <a href="javascript:void(0);" class="yellow view-todo-in-node"><%= jsResources.lang.ViewMore %></a>
                <%= jsResources.lang.CreateFlowNodeGridTodoInNode %>
            </span>
        </td>
    </tr>
    <% if( max > 0 ) {%>
        <% for( var i = 0; i < max; i++ ){ %>
            <tr class="<%= i == max-1 ? "last" :"" %>">
                <td>
                    <% if( i < uinLength ){ %>
                        <% var uinItem = model.UserInNode[i] %>
                        <span>
                            <input type="checkbox" <%= uinItem.Selected == true ? 'checked="checked"' : '' %> title="<%= jsResources.lang.CreatFlowMainExcutorTitle %>" class="UserInNodeMainExecutor" data-id="<%= uinItem.Key %>" />
                        </span>
                        <span>
                            <%= uinItem.Value %>
                        </span>
                        <span>
                            <a href="javascript:void(0)" data-id="<%= uinItem.Key%>" class="red delete-user-in-node"><%= jsResources.lang.GridDelete %></a>
                        </span>
                    <% } %>
                </td>
                <td>
                    <% if (i < tinLength ) { %>
                        <% var tinItem = model.TodoInNode[i] %>
                        <span>
                            <%= tinItem.Value %>
                        </span>
                        <span>
                            <a href="javascript:void(0)" data-id="<%= tinItem.Key%>" class="red delete-todo-in-node"><%= jsResources.lang.GridDelete %></a>
                        </span>
                    <% } %>
                </td>
            </tr>    
        <% } %>
    <% } %>
    <tr class="space"></tr>

</script>
<script id="node-relation-item-template" type="text/template">
    <div class="w" id="<%=VOFFICE.CreateFlow.Prefix%><%= model.id %>" data-id="<%= model.id%>" relation="<%= model.NextNodeJson %>" style="top:<%= model.top + "px" %>;left:<%= model.left+ "px"%>;">
        <div id="name-<%= model.id %>" title="<%= model.Description%>"><%= model.Name %></div>
        <div class="ep"></div>
    </div>
</script>
<script id="todo-form-template" type="text/template">
    <div id="todo-form-error"/>
    <form id="todo-form" onsubmit="return false;">
        <ul class="idata-form">
        <li class="title">
            <%= jsResources.lang.CreateFlowTodoTitle %>
        </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowTodoFormTitle %>    
                </span>
                <span>
                    <input type="text" name="Todo_Name" id="Todo_Name"  value="<%= model.Name %>" required/>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowTodoFormDescription %>    
                </span>
                <span>
                    <textarea name="Todo_Description" id="Todo_Description"  value="" ><%= model.Description %></textarea>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowTodoFormTemplate %>   
                </span>
                <span>
                    <span class="span-library-item-name"><%= model.LibraryItemName %></span>
                    <a href="javascript:void(0)" class="choose-from-library"><%= jsResources.lang.CreateFlowTodoFormChooseLib %></a>
                    <div id="todo-upload-button"></div>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowTodoFormProcess %>
                </span>
                <span>
                    <input type="checkbox" <%= model.IsCheckList == false ? 'checked ="checked"' :''%> name="Todo_IsCheckList" id="Todo_IsCheckList"/>
                </span>
            </li>
            <li>
                <span class="idata-form-title">
                    <%= jsResources.lang.CreateFlowTodoFormActive %>
                </span>
                <span>
                    <input type="checkbox" <%= model.IsActive == true ? 'checked ="checked"' :''%> name="Todo_IsActive" id="Todo_Active"/>
                </span>
            </li>
        </ul>
        <div class="clear"/>
        <center>
            <input type="submit" value = "<%= model.id == 0 ? jsResources.lang.Create : jsResources.lang.Update %>" id="submit-book"
            class="ui-button ui-widget ui-state-default ui-corner-all ui-state-hover" role="button" aria-disabled="false"/>
        </center>
    </form>

</script>
<script id="todo-grid-template" type="text/template">
<table>
    <tr>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
    <tr>
    <% if(!!models && models.length > 0) { %>
        <% for(var i = 0; i < models.length; i++){ %>
            <% var model = models[i] %>
            <tr>
                <td>
                    <%= i %>
                </td>
                <td>
                    <%= model.Name %>
                </td>
                <td>
                    <%= model.Description %>
                </td>
                <td>
                    <%= model.LibraryItemName %>
                </td>
                <td>
                    <%= model.NodeName %>
                </td>
                <td>
                    <input type="checkbox" disabled <%= model.IsActive == true ? 'checked ="checked"' : '' %> />
                </td>
                <td>
                    <a href = "javascript:void(0)" data-id = "<%= model.id %>">jsResources.lang.GridDelete</a>
                </td>
            </tr>
        <% } %>
    <% } %>
</table>
</script>
